#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

const int maxk=15, maxc=6, mods=1000000007;

int c[maxk*maxc+1][maxk*maxc+1];

int main() {
#ifdef DEBUG
  freopen("2821.in", "r", stdin);
  freopen("2821.out", "w", stdout);
#endif

  for (int i=0; i<=maxc*maxk; i++) {
    c[i][0] = 1;
    for (int j=1; j<=i; j++) {
      c[i][j] = (c[i-1][j] + c[i-1][j-1])%mods;
    }
  }

  int t;
  scanf("%d", &t);
  for (int ti=1; ti<=t; ti++) {
    static int col[maxk+1];
    static long long f[maxk+1][maxk*maxc+1];
    int k;
    scanf("%d", &k);
    for (int i=1; i<=k; i++) {
      scanf("%d", col+i);
    }
    memset(f, 0, sizeof(f));
    f[0][0] = 1;
    for (int i=0, s=0; i<k; i++) {
      s += col[i];
      for (int j=0; j<=s; j++) {
	for (int k=1; k<=col[i+1]; k++) {
	  for (int l=0; l<=k; l++) {
	    if (j+col[i+1]-k-l>=0) {
	      f[i+1][j+col[i+1]-k-l] = (f[i+1][j+col[i+1]-k-l]+f[i][j]*c[col[i+1]-1][k-1]%mods*c[j][l]*c[s+1-j][k-l])%mods;
	    }
	  }
	}
      }
    }
    printf("%lld\n", f[k][0]);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
